import { createRouter, createWebHistory } from "vue-router";
import Index from "../views/index.vue";
import ApiIndex from "../views/api/index.vue";
import Ds from "../views/base/ds.vue";
import LogIndex from "../views/api/logs/Index.vue";

const routes = [
    {
        path: "/",
        component: Index,
        children: [
            {
                path: "/apis",
                children: [
                    {
                        path: "/",
                        redirect: "/apis/stat",
                        meta: {
                            title: "概览",
                        },
                    },
                    {
                        path: "/apis/list",
                        component: ApiIndex,
                        meta: {
                            title: "接口列表",
                        },
                    },
                    {
                        path: "/apis/editor",
                        component: () => import("../views/api/editor.vue"),
                        meta: {
                            title: "接口编辑",
                        },
                    },
                    {
                        path: "/apis/doc",
                        component: () => import("../views/api/doc.vue"),
                        meta: {
                            title: "接口文档",
                        },
                    },
                    {
                        path: "/apis/supplier",
                        component: () => import("../views/api/supplier/index.vue"),
                        meta: {
                            title: "接入方管理",
                        },
                    },
                    {
                        path: "/apis/supplier-auth/:id",
                        component: () => import("../views/api/supplier/supplier-auth.vue"),
                        meta: {
                            title: "鉴权管理",
                        },
                    },
                    {
                        path: "/apis/schedule-task",
                        component: () => import("../views/api/schedule-task.vue"),
                        meta: {
                            title: "定时任务",
                        },
                    },
                    {
                        path: "/apis/logs",
                        component: LogIndex,
                        meta: {
                            title: "运行日志",
                        },
                    }, {
                        path: "/apis/stat",
                        component: () => import("../views/api/stat.vue"),
                        meta: {
                            title: "数据概览",
                        },
                    }, {
                        path: "/apis/browser",
                        component: () => import("../views/api/browser.vue"),
                        meta: {
                            title: "接口浏览",
                            pad: false
                        },
                    },
                ],
            },
            {
                path: "/sys",
                children: [
                    {
                        path: "/sys/client",
                        component: () => import("../views/base/client.vue"),
                        meta: {
                            title: "客户端管理",
                        },
                    },
                    {
                        path: "/sys/client-apis/:id",
                        component: () => import("../views/base/client-apis.vue"),
                        meta: {
                            title: "客户端授权",
                        },
                    },
                    {
                        path: "/",
                        redirect: "/sys/dept",
                    },
                    {
                        path: "/sys/dept",
                        name: "sysDept",
                        component: () => import("../views/sys/dept.vue"),
                        meta: {
                            title: "组织管理",
                        },
                    },
                    {
                        path: "/sys/user",
                        name: "sysUser",
                        component: () => import("../views/sys/user.vue"),
                        meta: {
                            title: "用户管理",
                        },
                    },
                    {
                        path: "/sys/menu",
                        name: "sysMenu",
                        component: () => import("../views/sys/menu.vue"),
                        meta: {
                            title: "菜单管理",
                        },
                    },
                    {
                        path: "/sys/role",
                        name: "sysRole",
                        component: () => import("../views/sys/role/index.vue"),
                        meta: {
                            title: "角色管理",
                        },
                    },
                    {
                        path: "/sys/config",
                        name: "sysConfig",
                        component: () => import("../views/sys/config.vue"),
                        meta: {
                            title: "配置管理",
                        },
                    },
                    {
                        path: "/sys/dict",
                        name: "sysDict",
                        component: () => import("../views/sys/dict/index.vue"),
                        meta: {
                            title: "字典管理",
                        },
                    },
                ],
            },
            {
                path: "/monitor",
                children: [
                    {
                        path: "/monitor/online",
                        component: () => import("../views/monitor/online.vue"),
                        meta: {
                            title: "在线用户",
                        },
                    },{
                        path: "/monitor/login-log",
                        component: () => import("../views/monitor/user-login.vue"),
                        meta: {
                            title: "登录日志",
                        },
                    },{
                        path: "/monitor/operation",
                        component: () => import("../views/monitor/user-log.vue"),
                        meta: {
                            title: "操作日志",
                        },
                    },
                ],
            },
            {
                path: "/etl-manager",
                children: [
                    {
                        path: "/etl/job",
                        component: () => import("../views/etl/job.vue"),
                        meta: {
                            title: "任务管理",
                        },
                    },
                    {
                        path: "/etl/logs",
                        component: () => import("../views/etl/logs.vue"),
                        meta: {
                            title: "执行日志",
                        },
                    },
                ],
            },
            {
                path: "/base",
                children: [
                    {
                        path: "/base/ds",
                        component: Ds,
                        meta: {
                            title: "数据源管理",
                        },
                    },
                    {
                        path: "/base/model",
                        component: () => import("../views/base/model/index.vue"),
                        meta: {
                            title: "数据模型管理",
                        },
                    },
                    {
                        path: "/base/model-data",
                        component: () => import("../views/base/model-data/index.vue"),
                        meta: {
                            title: "数据模型管理",
                        },
                    },
                ],
            },
            {
                path: '/data/view',
                component: () => import('../views/data-view/index.vue'),
                meta: {
                    title: '数据渲染'
                }
            }
        ],
    },
    {
        path: "/login",
        component: () => import("../views/sys/login.vue"),
    },
];

const router = createRouter({
    routes,
    history: createWebHistory(),
});

export default router;
